def max_split(nums):
    total = sum(nums)
    nums_sorted = sorted(nums, reverse=True)
    max_m = 0
    max_possible_m = min(len(nums), total)
    
    for m in range(max_possible_m, 0, -1):
        if total % m != 0:
            continue
        target = total // m
        if any(num > target for num in nums_sorted):
            continue
        
        buckets = [0] * m
        for num in nums_sorted:
            idx = -1
            min_sum = float('inf')
            for i in range(m):
                if buckets[i] + num <= target and buckets[i] < min_sum:
                    min_sum = buckets[i]
                    idx = i
            if idx == -1:
                break
            buckets[idx] += num
        else:
            if all(b == target for b in buckets):
                return m
    return 1


# 测试用例
if __name__ == "__main__":    
    # 测试用例
    test_cases = [
        [6, 4, 3, 3, 2],
        [10, 8, 6, 4, 2],
        [7, 7, 7],
        [5, 4, 3, 2, 1],
        [5, 4, 3, 2],
    ]
    
    for i, test in enumerate(test_cases):
        print(f"测试用例 {i+1} {test}: 最大的m值为 {max_split(test)}")
